const express = require('express');
const router = express.Router();
const {
    getAllUsers,
    getUserById,
    createUser,
    updateUser,
    deleteUser,
    getAllOrders,
    getOrderById,
    updateOrder,
    deleteOrder,
    getAllReviews,
    updateReview,
    deleteReview,
    checkOverdueOrders,
    getVerifications,
    updateVerification
} = require('../controllers/adminController');
const { verifyToken } = require('../utils/jwt');
const { isAdmin } = require('../middleware/adminAuth');

// 所有路由都需要管理员权限
router.use(verifyToken(), isAdmin);

// 用户管理路由
router.get('/users', getAllUsers);
router.get('/users/:id', getUserById);
router.post('/users', createUser);
router.put('/users/:id', updateUser);
router.delete('/users/:id', deleteUser);

// 订单管理路由
router.get('/orders', getAllOrders);
router.get('/orders/:id', getOrderById);
router.put('/orders/:id', updateOrder);
router.delete('/orders/:id', deleteOrder);

// 评论管理路由
router.get('/reviews', getAllReviews);
router.put('/reviews/:id', updateReview);
router.delete('/reviews/:id', deleteReview);

// 认证审核路由
router.get('/verifications', getVerifications);
router.put('/verifications/:id', updateVerification);

// 系统维护路由
router.post('/system/check-orders', checkOverdueOrders);

module.exports = router;